package com.jml.装饰模式.五期.异步多渠道群发框架.listener;

import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

//使用ContextRefreshedEvent会再spring上下文刷星的时候调用，会调用多次
//使用ApplicationEvent需要我们手动去调用，不会自己调用
@Component
public class EmailListener003 implements ApplicationListener<ApplicationEvent> {
    /**
     * 监听的方法
     *
     * @param event
     */
    @Override
    @Async
    public void onApplicationEvent(ApplicationEvent event) {
        System.out.println(Thread.currentThread().getName()+"邮件:" + event.toString());
    }
}
